#!/usr/bin/python

import subprocess
from datetime import datetime, timedelta

n = 16
totala = timedelta(seconds=0)
totalb = timedelta(seconds=0)
command = "./sort{} < in2 > /tmp/out2"
for i in range(n):
    print(i)
    start = datetime.now()
    subprocess.call(
        command.format('a'),
        stderr=subprocess.STDOUT,
        shell=True)
    totala += datetime.now() - start
    start = datetime.now()
    subprocess.call(
        command.format('b'),
        stderr=subprocess.STDOUT,
        shell=True)
    totalb += datetime.now() - start
averagea = totala.total_seconds() / n
averageb = totalb.total_seconds() / n
print('a: {} b:{}'.format(averagea, averageb))
